<%--
    Document   : City
    Created on : 25/04/2010, 15:39:20
--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="br.terminalrodoviario.City"%>
<jsp:useBean class="br.terminalrodoviario.City" id="city" scope="page"/>
<%
            String id = request.getParameter("id");
            if (id != null) {
                city = new City().selectById("Select c from City c where c.id = " + id);
            }
%>

<jsp:useBean class="br.terminalrodoviario.User" id="user" scope="session"/>
<%
        if (user.getId() == 0) {
            response.sendRedirect("../login.jsp");
        }
%>

<script type="text/javascript">
    function verifyFields(){
        var txtName = document.getElementById("txtName");
        var cboState = document.getElementById("cboState");
        document.getElementById('validate').innerHTML = '';
        document.getElementById('validate1').innerHTML = '';
        var fill = true;
        if(txtName.value==""){
            document.getElementById('validate').innerHTML = 'Informe o nome';
            fill=false;
        }
        if(cboState.value=="" || cboState.value==null){
            document.getElementById('validate1').innerHTML = 'Selecione o estado';
            fill=false;
        }
        if(fill==false)
            return;
        document.getElementById("form").submit();
    }

</script>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Guia Terminal Rodoviário</title>
        <style type="text/css">
            @import url("../../add/css/cssAdmin.css");
            @import url("../../add/css/rodape.css");
        </style>
    </head>
    <body>
        <div class="geral">
            <table>
                <tr>
                    <td>
                        <div id="cabecalho">
                        </div>
                    </td>
                </tr>
            </table>
            <table id="menuAdmin" width="762">
                <tr >
                    <td>
                        <ul class="menuCidade" >
                            <li class="current"><a href="../Manager/MCity.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuEmpresa" >
                            <li><a href="../Manager/MCompany.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuTerminais" >
                            <li><a href="../Manager/MBusStation.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuHoteis" >
                            <li><a href="../Manager/MHotel.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuNoticias" >
                            <li><a href="../Manager/MNotice.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuSolicitacao" >
                            <li><a href="../Manager/MSolicitation.jsp" /></li>
                        </ul>
                    </td>
                    <td>
                        <ul class="menuDicas" >
                            <li><a href="../Manager/MTravelTip.jsp" /></li>
                        </ul>
                    </td>

                </tr>
            </table>

            <div style="float:left">
                <br/>
                <b><a href="../index.jsp">Início</a> -> <a href="../Manager/MCity.jsp">Cidades</a> -> <a href="FCity.jsp">Cadastrar Cidade</a></b>
                <br/><br/>
            </div>
            <div align="right" style="font-family:calibri; font-size:11px; font-style:inherit">
                <br/>Bem-vindo <b><%=request.getSession().getAttribute("username")%></b>,<br/>
                você está logado desde <%=request.getSession().getAttribute("date_session")%>h. ( <a href="../logout.jsp"><b>Logout</b></a> )<br/><br/>
            </div>

            <table  id="subTitulo">
                <tr>
                    <td id="icone">
                        &nbsp;&nbsp;&nbsp;<img src="../../add/images/icones/city.png" alt="Cidade" title="Cidade"/>
                    </td>
                    <td>
                        Cidades
                    </td>
                </tr>
            </table>
            <br>

            <form name="form" id="form" action="../CityServlet?acao=gravar&id=<%=request.getParameter("id")%>" method="post">
                <div align="right"><b style="color:red">(*) campos obrigatórios</b></div>
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="label_bg" style="width:150px;">&nbsp;&nbsp;Nome:</td>
                        <td>&nbsp;&nbsp;<input id="txtName" type="text" name="txtName" maxlength="50" value="<%=city.getName() == null ? "" : city.getName()%>" size="37"> <b style="color:red">*</b> <b id="validate"></b></td>
                    </tr>
                    <tr>
                        <td class="label">&nbsp;&nbsp;Estado:</td>
                        <td>&nbsp;
                            <select class="calibri" id="cboState" name="cboState" style="width:250px; height:22px;">
                                <option value="AC" <%=city.getState() != null && city.getState().equals("AC") ? "selected='true'" : ""%>>Acre</option>
                                <option value="AL" <%=city.getState() != null && city.getState().equals("AL") ? "selected='true'" : ""%>>Alagoas</option>
                                <option value="AM" <%=city.getState() != null && city.getState().equals("AM") ? "selected='true'" : ""%>>Amazonas</option>
                                <option value="AP" <%=city.getState() != null && city.getState().equals("AP") ? "selected='true'" : ""%>>Amapá</option>
                                <option value="BA" <%=city.getState() != null && city.getState().equals("BA") ? "selected='true'" : ""%>>Bahia</option>
                                <option value="CE" <%=city.getState() != null && city.getState().equals("CE") ? "selected='true'" : ""%>>Ceará</option>
                                <option value="DF" <%=city.getState() != null && city.getState().equals("DF") ? "selected='true'" : ""%>>Distrito Federal</option>
                                <option value="ES" <%=city.getState() != null && city.getState().equals("ES") ? "selected='true'" : ""%>>Espírito Santo</option>
                                <option value="GO" <%=city.getState() != null && city.getState().equals("GO") ? "selected='true'" : ""%>>Goiás</option>
                                <option value="MA" <%=city.getState() != null && city.getState().equals("MA") ? "selected='true'" : ""%>>Maranhão</option>
                                <option value="MT" <%=city.getState() != null && city.getState().equals("MT") ? "selected='true'" : ""%>>Mato Grosso</option>
                                <option value="MS" <%=city.getState() != null && city.getState().equals("MS") ? "selected='true'" : ""%>>Mato Grosso do Sul</option>
                                <option value="MG" <%=city.getState() != null && city.getState().equals("MG") ? "selected='true'" : ""%>>Minas Gerais</option>
                                <option value="PA" <%=city.getState() != null && city.getState().equals("PA") ? "selected='true'" : ""%>>Pará</option>
                                <option value="PB" <%=city.getState() != null && city.getState().equals("PB") ? "selected='true'" : ""%>>Paraíba</option>
                                <option value="PR" <%=city.getState() != null && city.getState().equals("PR") ? "selected='true'" : ""%>>Paraná</option>
                                <option value="PE" <%=city.getState() != null && city.getState().equals("PE") ? "selected='true'" : ""%>>Pernambuco</option>
                                <option value="PI" <%=city.getState() != null && city.getState().equals("PI") ? "selected='true'" : ""%>>Piauí</option>
                                <option value="RJ" <%=city.getState() != null && city.getState().equals("RJ") ? "selected='true'" : ""%>>Rio de Janeiro</option>
                                <option value="RN" <%=city.getState() != null && city.getState().equals("RN") ? "selected='true'" : ""%>>Rio Grande do Norte</option>
                                <option value="RO" <%=city.getState() != null && city.getState().equals("RO") ? "selected='true'" : ""%>>Rondônia</option>
                                <option value="RS" <%=city.getState() != null && city.getState().equals("RS") ? "selected='true'" : ""%>>Rio Grande do Sul</option>
                                <option value="RR" <%=city.getState() != null && city.getState().equals("RR") ? "selected='true'" : ""%>>Roraima</option>
                                <option value="SC" <%=city.getState() != null && city.getState().equals("SC") ? "selected='true'" : ""%>>Santa Catarina</option>
                                <option value="SE" <%=city.getState() != null && city.getState().equals("SE") ? "selected='true'" : ""%>>Sergipe</option>
                                <option value="SP" <%=city.getState() != null && city.getState().equals("SP") ? "selected='true'" : ""%>>São Paulo</option>
                                <option value="TO" <%=city.getState() != null && city.getState().equals("TO") ? "selected='true'" : ""%>>Tocantins</option>
                            </select>
                            <b style="color:red">*</b> <b id="validate1"></b>
                        </td>
                    </tr>

                </table>
                <table>
                    <tr>
                        <td align="right" colspan="2" width="414"><input type="button" onclick="javascript:verifyFields();" align="right" value="Gravar" name="enviar">&nbsp;&nbsp;&nbsp;<br></td>
                    </tr>
                </table>
            </form>
            <br>
            <table id="rodape" style="background-image:url(../../add/images/rodape.png);">
                <tr>
                </tr>
            </table>
            <table id="btRodape" style="text-decoration: none;" >
                <tr>
                    <td align="center" width="80px">
                        <ul class="btYoutube">
                            <li><a title="Youtube" href="http://www.youtube.com" /></li>
                        </ul>
                    </td >
                    <td align="center" width="80px">
                        <ul class="btOrkut">
                            <li><a title="Orkut" href="http://www.orkut.com" /></li>
                        </ul>
                    </td>
                    <td align="center" width="205px">
                        <ul class="btTwitter">
                            <li><a title="Twitter" href="http://twitter.com" /></li>
                        </ul>
                    </td>
                    <td align="center">
                        <a title="Trabalhe Conosco" class="text" href="../../Carrer.jsp" >Trabalhe Conosco</a>
                    </td>
                    <td align="center"  width="">
                        <a title="Mapa do Site" class="text" href="../../SiteMap.jsp">Mapa do Site</a>
                    </td>
                    <td align="center" width="">
                        <a title="Contatos" class="text" href="../../Contact.jsp">Contatos</a>
                    </td>
                </tr>
            </table>
        </div>
    </body>
</html>
